/**
  ******************************************************************************
  * @file    APP_DATABASE.h
  * @author  Feirui_Joe
  * @version V0.1
  * @date    07/26/2010
  * @brief   Outputs Driver
  ******************************************************************************
  * @copy
  *
  * <h2><center>&copy; COPYRIGHT 2010 Feirui</center></h2>
  */ 



/* Define to prevent recursive inclusion -------------------------------------*/
#ifndef  __APP_DATABASE_H__
#define  __APP_DATABASE_H__


#ifdef __cplusplus
 extern "C" {
#endif


/**
  * @brief  INCLUDE FILES.
  */


/**
  * @brief GLOBALS RAM definition
  */
#ifdef   APP_GLOBALS_DATABASE
#define  APP_EXT_DATABASE
#else
#define  APP_EXT_DATABASE  extern
#endif


#define NibleOrd_H1st        0
#define NibleOrd_H2nd        1
#define NibleOrd_H3rd        2
#define NibleOrd_H4th        3


#define DataBaseLogicOperaFun_4ByteAdd           0
#define DataBaseLogicOperaFun_EnergyPKWUpd       1
#define DataBaseLogicOperaFun_EnergyPKvarUpd     2
#define DataBaseLogicOperaFun_2ByteAdd           3
APP_EXT_DATABASE uint8_t LogicOperaDataBaseDataContent(uint16_t address,uint32_t Data,uint8_t OperaFun);


APP_EXT_DATABASE uint8_t  CheckifDataBaseAddressAvail(uint16_t address);
APP_EXT_DATABASE uint8_t  GetDataBaseReadWritePermission(uint16_t address);
APP_EXT_DATABASE uint8_t  CheckDataBaseReadWritePermission(uint16_t address,uint8_t Opera);
APP_EXT_DATABASE uint8_t  GetDataBaseUserFunPermission(uint16_t address);
APP_EXT_DATABASE uint8_t  CheckDataBaseWriteUserFunPermission(uint16_t address,uint8_t Opera);
APP_EXT_DATABASE uint8_t  CheckDataBaseReadUserFunPermission(uint16_t address,uint8_t Opera);
APP_EXT_DATABASE uint32_t GetDataBaseParamMinValue(uint16_t address,uint8_t *DataType);
APP_EXT_DATABASE uint32_t GetDataBaseParamMaxValue(uint16_t address,uint8_t *DataType);
APP_EXT_DATABASE uint8_t  GetDataBaseParamRangeValue(uint16_t address,uint32_t *DataMin,uint32_t *DataMax);
APP_EXT_DATABASE uint8_t  GetDataBaseParamDataType(uint16_t address);

APP_EXT_DATABASE uint8_t  ReadDataBaseDataContent(uint16_t address,uint16_t *Buffer,uint8_t Number);
APP_EXT_DATABASE uint8_t  WriteDataBaseDataContent(uint16_t address,uint16_t *Buffer,uint8_t Number);
APP_EXT_DATABASE uint8_t  FillDataBaseDataContent(uint16_t address,uint16_t Value,uint8_t Number);
APP_EXT_DATABASE uint8_t  ModifyDataBaseDataContent(uint16_t address,uint16_t ClrVal,uint16_t SetVal,uint16_t NorVal);
APP_EXT_DATABASE uint8_t  ModifyNibleBaseDataContent(uint16_t address,uint8_t NibleOrd,uint8_t Value);
APP_EXT_DATABASE uint16_t GetDataBaseDataContent(uint16_t address);

APP_EXT_DATABASE uint16_t AdjustDoubleTypeValueByRangeLimit(double Value,uint16_t Address);
APP_EXT_DATABASE void AdjustValueByCfgRangeLimit(void *Value,uint16_t Address);
//APP_EXT_DATABASE uint8_t *StringCopyCheckAPPSemLengthLimit(OS_EVENT *Pevent,uint8_t *stringTarget,uint8_t *stringSource,uint16_t MaxLength);



#ifdef __cplusplus
}
#endif


#endif   /*  __APP_DATABASE_H__  */

/******************* (C) COPYRIGHT 2010 Feirui *****END OF FILE****/
